/*----------------------------------------------------------------------------
Owner(s): Shane Whitfield
$Copyright: $
$Id: $
----------------------------------------------------------------------------*/

#include "nodemgr.h"
#include "go.h"

/*--------------------------------------------------------------------------*/

CNodeMgr::CNodeMgr() : super("nodemgr")
{
	m_rootNode = NULL;
}

void CNodeMgr::OnPostWorldUpdate()
{
	if (m_rootNode == NULL)
	{
		printf("Error: No root node!\n");
		return;
	}
	
	m_rootNode->VisitNode();
	m_rootNode->VisitNodesChildren();
}

void CNodeMgr::OnPostWorldUnload()
{
	m_rootNode = NULL;
}
	

void CNodeMgr::RegisterRootNode(CGoNode* i_rootNode)
{
	//make sure NULL isn't being passed in
	if (i_rootNode == NULL)
	{
		printf("Error: root as NULL passed in to nodemgr!\n");
		return;
	}
	
	//make sure the first node is the root
	if (m_rootNode)
	{
		printf("Error: Root isn't the first node in node mgr!\n");
		return;
	}
	
	m_rootNode = i_rootNode;
}

/*-----------------------------------EOF!-----------------------------------*/ 